#ifndef T_BOX_INPUT_HTTP_H
#define T_BOX_INPUT_HTTP_H

#include "t_box_input.h"

#include <QtNetwork>

class T_Box_Input_Http : public T_Box_Input
{
public:
    static const int c_pd_check_size = 4096;
    static const int c_buffer_size = 1024;
    quint8 *m_buffer;
    QMutex m_mutex;
    QNetworkReply *m_reply;
    NetworkWaiter m_waiter;
    QByteArray m_file_bytes;
    QBuffer m_file;
    QFile m_temp_flv;
    QByteArray m_pd_bytes;
    QByteArray m_first_read;
    T_Box_Input_Http(QNetworkReply *a_reply);
    ~T_Box_Input_Http();
    virtual bool isValid();
    AVInputFormat *getAVInputFormat();
    ByteIOContext *getByteIOContext();
    AVFormatContext	*getAVFormatContext();
    virtual T_Box_Player_Context *getAVFormatContext2();
    int read_packet(uint8_t *buf, int buf_size);
    int64_t seek(int64_t offset, int whence);
protected:
    static int callback_read_packet(void *opaque, uint8_t *buf, int buf_size)
    {
        T_Box_Input_Http *self = (T_Box_Input_Http *)opaque;
        return self->read_packet(buf, buf_size);
    }
    static int64_t callback_seek(void *opaque, int64_t offset, int whence)
    {
        T_Box_Input_Http *self = (T_Box_Input_Http *)opaque;
        return self->seek(offset, whence);
    }
};

#endif // T_BOX_INPUT_HTTP_H
